﻿using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Shapes;

namespace GasPumpingUnitPrediction
{
    public partial class MainWindow : Window
    {
        private double xmin = 0;

        private double xmax = 6.5;
        private double ymin = -1.1;
        private double ymax = 1.1;
        private Polyline pl;

        public MainWindow()
        {
            InitializeComponent();
            AddChart();
        }

        private void AddChart()
        {
            // Draw sine curve:
            pl = new Polyline();
            pl.Stroke = Brushes.Black;
            for (int i = 0; i < 70; i++)
            {
                double x = i / 5.0;
                double y = Math.Sin(x);
                pl.Points.Add(CurvePoint(
                    new Point(x, y)));
            }
            functionCanvas.Children.Add(pl);
            // Draw cosine curve:
            pl = new Polyline();
            pl.Stroke = Brushes.Black;
            pl.StrokeDashArray = new DoubleCollection(
                new double[] { 4, 3 });
            for (int i = 0; i < 70; i++)
            {
                double x = i / 5.0;
                double y = Math.Cos(x);
                pl.Points.Add(CurvePoint(
                    new Point(x, y)));
            }
            functionCanvas.Children.Add(pl);
        }
        private Point CurvePoint(Point pt)
        {
            Point result = new Point();
            result.X = (pt.X - xmin) * functionCanvas.Width / (xmax - xmin);
            result.Y = functionCanvas.Height - (pt.Y - ymin) * functionCanvas.Height
                       / (ymax - ymin);
            return result;
        }

        private void gridSplitter1_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e)
        {
        }
    }
}
